package com.feng.service.impl;

import com.feng.entity.User;
import com.feng.service.PermissionService;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Service;

@Service("ps")
public class PermissionServiceImpl implements PermissionService {


    @Override
    public boolean hasPermission(String permission) {
        User user = (User)SecurityContextHolder.getContext().getAuthentication().getPrincipal();
        if(user.getAccount().getType() == 1)
            return true;
        return user.getPermissions().contains(permission);
    }
}
